//
// Created by 吴楷泓 on 2021/12/17.
//
#include <stdio.h>
#include <string.h>
#include <stdlib.h>



//void swap(int* a, int *b) {
//    int t;
//    t = *a, *a = *b, *b = t;
//}

void swap(void * ptr1, void* ptr2, int size) { // 通用swap函数
    void *buffer = malloc(size);
    memcpy(buffer, ptr1, size);
    memcpy(ptr1, ptr2, size);
    memcpy(ptr2, buffer, size);
}

int Delete(int arr[], int temp[], int* length, int target) {
    int i, count = 0, index = 1;
    for(i = 1; i <= *length; i++) {
        if(arr[i] != target) {
            temp[index++] = arr[i];
        } else {
            count++;
        }
    }

    memcpy(arr, temp, 10 * sizeof(int));
    *length -= count;
    return count;
}

void Sort(int arr[], int length) {
    int i, j;
    for(i = 1; i <= length; i++) {
        int min = i;
        for (j = i + 1; j <= length; j++) {
            if (arr[j] < arr[min]) {
                min = j;
            }
        }
        swap(&arr[i], &arr[min], sizeof(arr[i]));
    }
}



int main() {
    int arr[11];
    int temp[11];
    int length = 10;
    int target;
    int i;
    for(i = 1; i <= 10; i++) {
        scanf("%d", &arr[i]);
    }
    scanf("%d", &target);
    Delete(arr, temp, &length, target);
    Sort(arr, length);
    for(i = 1; i <= length; i++) {
        printf("%d%c", arr[i], i % 3 ? ',' : '\n');
    }
    return 0;
}


